from flask import Flask
from flask_mail import Mail

from models import db
from views import index_blu, passport_blu, user_blu,comment_blu
from flask_migrate import Migrate, Manager, MigrateCommand

app = Flask(__name__)

app.config.from_pyfile('config.ini')
app.register_blueprint(index_blu)
app.register_blueprint(passport_blu)
app.register_blueprint(user_blu)
app.register_blueprint(comment_blu)


db.init_app(app)


mail =Mail()

mail.init_app(app)


# 添加数据库迁移等工具
manager = Manager(app)
# 生成migrate对象 用来数据库迁移
migrate = Migrate(app, db)
# 添加db命令
manager.add_command('db', MigrateCommand)
if __name__ == '__main__':
    # app.run( port=8989)
    manager.run()
